﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace SBPweb.RIA.Client.Controls.Content
{

    public class ExtendedRichTextBox : RichTextBox
    {

        private ScrollViewer scrollViewer;
        
        public void ScrollToBottom()
        {
            if (scrollViewer != null)
            {
                scrollViewer.UpdateLayout();
                scrollViewer.ScrollToVerticalOffset(double.MaxValue);
            }
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            scrollViewer = GetTemplateChild("ContentElement") as ScrollViewer;
        }

    }

}